/** <!--------------------------------------------------------------------------------------------->
 * @file XXXXXXX.XXX
 *
 * GSvn - A Graphical Client for SVN
 * Copyright (C) 2012  Karl Krach, gsvn@bluespirit.la
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 <!---------------------------------------------------------------------------------------------> */


#ifndef GRAPHBRANCH_H
#define GRAPHBRANCH_H

#include <QGraphicsItem>
#include <QPainter>
#include <QGraphicsDropShadowEffect>
#include <QMenu>
#include <QAction>
#include <QObject>
#include <QGraphicsSceneContextMenuEvent>
#include <QDebug>

#include <QGraphicsWidget>
#include <QGraphicsScene>
#include "GraphItem.h"
#include "GeometryChangeListener.h"

class GraphBranch : public QObject, public QGraphicsItem, public GeometryChangeListener
{
	Q_OBJECT
	Q_INTERFACES( QGraphicsItem )

public:
	GraphBranch( const QString& strName );

	/* Methods */
public:

	void SetHeight( float fHeight );

	void GeometryHasChanged();

	bool Scroll( int iSteps );

	QString GetName() { return m_strName; }

	/* Override Methods */
public:

	QRectF boundingRect() const;

	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

	QVariant itemChange( GraphicsItemChange eChange, const QVariant& oValue );


	/* Public Slots */
public slots:



	/* Protected Methods */
protected:

	bool RearrangeItems();


	/* Members */
private:

	static const int S_TEXT_MARGIN = 20;
	static const int S_MARGIN_TOP = 40+S_TEXT_MARGIN;
	QString m_strName;
	QVector<GraphItem*> m_aRevisions;
	float m_fWidth;
	float m_fHeight;
	static const int s_iBorder = 5;
	//QGraphicsDropShadowEffect* m_pShadowEffect;
	QGraphicsItem* m_pRefItem;
	float m_fNextItemTop;
	int m_iFirstItem;
	int m_iLineStart;
};

#endif // GRAPHBRANCH_H
